package com.lyc.blog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/fm")
public class FreeMarkerController {

    @GetMapping("/test1")
    public String fmTest1(Model model) {
        Map<String, String> map = new HashMap<>();
        map.put("user", "张三");
        model.addAttribute("data",map);
//        model.addAttribute("user", "Jack");
        return "fm/fmtest";
    }

    @GetMapping("/test2")
    public String fmTest2(Model model) {
        List<String> names = Arrays.asList("张三", "李四", "王五", "赵六", "田七", "王八");
        model.addAttribute("names", names);
        return "fm/fmlist";
    }
}
